package com.souche.employment.mapper;

import org.apache.ibatis.annotations.*;

import com.souche.employment.domain.JobDO;

import java.util.List;

/**
 * userMapper.java created at 2017年8月9日 下午2:23:36
 *
 * @author Ray [email:rayinhangzhou@hotmail.com]
 * Revision History
 * Date            Programmer                   Notes
 * ----------------------------------------------------------
 **/
@Mapper
public interface JobMapper {

    @Select("select * from job where id = #{jobId}")
    JobDO getJob(String jobId);

    @Insert("insert into job (id, name, dep1, dep2, jd, creator, date_create) values(#{id}, #{name}, #{dep1}, #{dep2}, #{jd}, #{creator}, now())")
    void addJob(JobDO jobDO);

    @Update("update job set name=#{name}, dep1=#{dep1}, dep2=#{dep2}, jd=#{jd}, creater=#{creater} where id=#{id}")
    void updateJob(JobDO jobDO);

    @Select("select id, name, dep1, dep2 from job where date_delete=0 order by date_update desc")
    List<JobDO> getJobsForList();

    @SelectProvider(type = SqlProvider.class, method = "findJobs")
    @Results({
            @Result(property = "dateCreate", column = "date_create"),
            @Result(property = "dateUpdate", column = "date_update")
    })
    List<JobDO> findJobs(@Param("name") String name, @Param("dep1") String dep1, @Param("dep2") String dep2, @Param("sort") String sort);


}
